home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 May / maximum-cd-1999-05.iso / Canvas 6 / DATA1.CAB / English_Tutorial_Files / Viewpage / ColMedia.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-04  |  2.7 KB  |  129 lines

  1. import java.awt.Event;
  2. import java.awt.Graphics;
  3. import java.awt.Rectangle;
  4. import java.io.DataInputStream;
  5. import java.io.IOException;
  6.  
  7. final class ColMedia extends ColObj {
  8.    protected ColGrph m_colGraphicObj;
  9.    private ColObjIntr[] m_colObj;
  10.    private byte playType;
  11.    private long[] m_delay;
  12.    private int numItems;
  13.    private long numTicks = 0L;
  14.    private int curIndex;
  15.    private boolean animationDone;
  16.    private boolean muted;
  17.    private boolean inDraw;
  18.    public Rectangle m_bounds;
  19.  
  20.    public boolean EventProc(Event var1) {
  21.       boolean var4 = false;
  22.       if (var1 != null) {
  23.          if (var1.key == 6969) {
  24.             this.muted = true;
  25.             var4 = true;
  26.          }
  27.  
  28.          if (var1.key == 6970) {
  29.             this.muted = false;
  30.             var4 = true;
  31.          }
  32.  
  33.          if (var1.key == 6971) {
  34.             this.PlayClip();
  35.             var4 = true;
  36.          }
  37.  
  38.          if (var1.id == 502) {
  39.             int var2 = (int)(((float)var1.x + this.m_colGraphicObj.m_xOrg * this.m_colGraphicObj.m_mag) / this.m_colGraphicObj.m_mag);
  40.             int var3 = (int)(((float)var1.y + this.m_colGraphicObj.m_yOrg * this.m_colGraphicObj.m_mag) / this.m_colGraphicObj.m_mag);
  41.             if (this.m_bounds.inside(var2, var3) && this.playType == 2) {
  42.                this.PlayClip();
  43.                var4 = true;
  44.             }
  45.          }
  46.       }
  47.  
  48.       if (!this.animationDone && !var4 && !this.inDraw) {
  49.          long var5 = System.currentTimeMillis();
  50.          if (var5 > this.numTicks) {
  51.             this.numTicks = System.currentTimeMillis() + this.m_delay[this.curIndex];
  52.             Graphics var7 = this.m_colGraphicObj.m_appComp.getGraphics();
  53.             this.inDraw = true;
  54.             this.draw(var7);
  55.             this.m_colGraphicObj.m_appComp.getToolkit().sync();
  56.             var7.dispose();
  57.             this.inDraw = false;
  58.             if (!this.animationDone) {
  59.                ++this.curIndex;
  60.                if (this.curIndex == this.numItems) {
  61.                   this.curIndex = 0;
  62.                   if (this.playType > 1) {
  63.                      this.animationDone = true;
  64.                   }
  65.  
  66.                   System.gc();
  67.                }
  68.             }
  69.          }
  70.       }
  71.  
  72.       return var4;
  73.    }
  74.  
  75.    public ColMedia(DataInputStream var1, int var2, ColGrph var3, Graphics var4) throws IOException {
  76.       super.cvObjNum = (long)var1.readInt();
  77.       this.numItems = var1.readInt();
  78.       this.playType = var1.readByte();
  79.       if (this.playType == 2) {
  80.          this.animationDone = true;
  81.       }
  82.  
  83.       this.m_colGraphicObj = var3;
  84.       this.m_delay = new long[this.numItems];
  85.       this.m_colObj = new ColObjIntr[this.numItems];
  86.       this.m_bounds = new Rectangle();
  87.       this.m_bounds.y = (int)((float)var1.readInt() / 65536.0F);
  88.       this.m_bounds.x = (int)((float)var1.readInt() / 65536.0F);
  89.       this.m_bounds.height = (int)((float)var1.readInt() / 65536.0F);
  90.       this.m_bounds.width = (int)((float)var1.readInt() / 65536.0F);
  91.  
  92.       for(int var5 = 0; var5 < this.numItems; ++var5) {
  93.          this.m_colGraphicObj.m_appComp.showStatus("Reading animation media " + var5 + " of " + (this.numItems - 1));
  94.          this.m_delay[var5] = (long)var1.readInt();
  95.          this.m_colObj[var5] = var3.m_appComp.m_colDoc.ReadNextObj(var1);
  96.          if (this.m_colObj[var5].getType() == 6) {
  97.          }
  98.       }
  99.  
  100.       this.numTicks = System.currentTimeMillis();
  101.    }
  102.  
  103.    public void draw(Graphics var1) {
  104.       if (this.m_colObj[this.curIndex].getType() == 16) {
  105.          if (!this.muted) {
  106.             ((ColSnd)this.m_colObj[this.curIndex]).PlayClip();
  107.             return;
  108.          }
  109.       } else {
  110.          this.m_colObj[this.curIndex].draw(var1);
  111.       }
  112.  
  113.    }
  114.  
  115.    public void PlayClip() {
  116.       this.animationDone = false;
  117.       this.curIndex = 0;
  118.       this.numTicks = System.currentTimeMillis();
  119.    }
  120.  
  121.    public int getType() {
  122.       return 14;
  123.    }
  124.  
  125.    public Rectangle getBounds() {
  126.       return this.m_bounds;
  127.    }
  128. }
  129.